//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS Pipes service.
///
/// Amazon EventBridge Pipes connects event sources to targets. Pipes reduces the need for specialized knowledge and integration code when developing event driven architectures. This helps ensures consistency across your company’s applications. With Pipes, the target can be any available EventBridge target. To set up a pipe, you select the event source, add optional event filtering, define optional enrichment, and select the target for the event data.
public struct Pipes: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the Pipes client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "Pipes",
            serviceIdentifier: "pipes",
            serviceProtocol: .restjson,
            apiVersion: "2015-10-07",
            endpoint: endpoint,
            errorType: PipesErrorType.self,
            xmlNamespace: "http://events.amazonaws.com/doc/2015-10-07",
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Create a pipe. Amazon EventBridge Pipes connect event sources to targets and reduces the need for specialized knowledge and integration code.
    @Sendable
    @inlinable
    public func createPipe(_ input: CreatePipeRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> CreatePipeResponse {
        try await self.client.execute(
            operation: "CreatePipe", 
            path: "/v1/pipes/{Name}", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Create a pipe. Amazon EventBridge Pipes connect event sources to targets and reduces the need for specialized knowledge and integration code.
    ///
    /// Parameters:
    ///   - description: A description of the pipe.
    ///   - desiredState: The state the pipe should be in.
    ///   - enrichment: The ARN of the enrichment resource.
    ///   - enrichmentParameters: The parameters required to set up enrichment on your pipe.
    ///   - kmsKeyIdentifier: The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt pipe data. The identifier can be the key  Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN. If you do not specify a customer managed key identifier, EventBridge uses an Amazon Web Services owned key to encrypt pipe data. For more information, see Managing keys in the Key Management Service Developer Guide.
    ///   - logConfiguration: The logging configuration settings for the pipe.
    ///   - name: The name of the pipe.
    ///   - roleArn: The ARN of the role that allows the pipe to send data to the target.
    ///   - source: The ARN of the source resource.
    ///   - sourceParameters: The parameters required to set up a source for your pipe.
    ///   - tags: The list of key-value pairs to associate with the pipe.
    ///   - target: The ARN of the target resource.
    ///   - targetParameters: The parameters required to set up a target for your pipe. For more information about pipe target parameters, including how to use dynamic path parameters, see Target parameters in the Amazon EventBridge User Guide.
    ///   - logger: Logger use during operation
    @inlinable
    public func createPipe(
        description: String? = nil,
        desiredState: RequestedPipeState? = nil,
        enrichment: String? = nil,
        enrichmentParameters: PipeEnrichmentParameters? = nil,
        kmsKeyIdentifier: String? = nil,
        logConfiguration: PipeLogConfigurationParameters? = nil,
        name: String,
        roleArn: String,
        source: String,
        sourceParameters: PipeSourceParameters? = nil,
        tags: [String: String]? = nil,
        target: String,
        targetParameters: PipeTargetParameters? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> CreatePipeResponse {
        let input = CreatePipeRequest(
            description: description, 
            desiredState: desiredState, 
            enrichment: enrichment, 
            enrichmentParameters: enrichmentParameters, 
            kmsKeyIdentifier: kmsKeyIdentifier, 
            logConfiguration: logConfiguration, 
            name: name, 
            roleArn: roleArn, 
            source: source, 
            sourceParameters: sourceParameters, 
            tags: tags, 
            target: target, 
            targetParameters: targetParameters
        )
        return try await self.createPipe(input, logger: logger)
    }

    /// Delete an existing pipe. For more information about pipes, see Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    @Sendable
    @inlinable
    public func deletePipe(_ input: DeletePipeRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DeletePipeResponse {
        try await self.client.execute(
            operation: "DeletePipe", 
            path: "/v1/pipes/{Name}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Delete an existing pipe. For more information about pipes, see Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    ///
    /// Parameters:
    ///   - name: The name of the pipe.
    ///   - logger: Logger use during operation
    @inlinable
    public func deletePipe(
        name: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeletePipeResponse {
        let input = DeletePipeRequest(
            name: name
        )
        return try await self.deletePipe(input, logger: logger)
    }

    /// Get the information about an existing pipe. For more information about pipes, see Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    @Sendable
    @inlinable
    public func describePipe(_ input: DescribePipeRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> DescribePipeResponse {
        try await self.client.execute(
            operation: "DescribePipe", 
            path: "/v1/pipes/{Name}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Get the information about an existing pipe. For more information about pipes, see Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    ///
    /// Parameters:
    ///   - name: The name of the pipe.
    ///   - logger: Logger use during operation
    @inlinable
    public func describePipe(
        name: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DescribePipeResponse {
        let input = DescribePipeRequest(
            name: name
        )
        return try await self.describePipe(input, logger: logger)
    }

    /// Get the pipes associated with this account. For more information about pipes, see Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    @Sendable
    @inlinable
    public func listPipes(_ input: ListPipesRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListPipesResponse {
        try await self.client.execute(
            operation: "ListPipes", 
            path: "/v1/pipes", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Get the pipes associated with this account. For more information about pipes, see Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    ///
    /// Parameters:
    ///   - currentState: The state the pipe is in.
    ///   - desiredState: The state the pipe should be in.
    ///   - limit: The maximum number of pipes to include in the response.
    ///   - namePrefix: A value that will return a subset of the pipes associated with this account. For example, "NamePrefix": "ABC" will return all endpoints with "ABC" in the name.
    ///   - nextToken: If nextToken is returned, there are more results available. The value of nextToken is a unique pagination token for each page.  Make the call again using the returned token to retrieve the next page. Keep all other arguments unchanged. Each pagination token expires after 24 hours. Using an expired pagination  token will return an HTTP 400 InvalidToken error.
    ///   - sourcePrefix: The prefix matching the pipe source.
    ///   - targetPrefix: The prefix matching the pipe target.
    ///   - logger: Logger use during operation
    @inlinable
    public func listPipes(
        currentState: PipeState? = nil,
        desiredState: RequestedPipeState? = nil,
        limit: Int? = nil,
        namePrefix: String? = nil,
        nextToken: String? = nil,
        sourcePrefix: String? = nil,
        targetPrefix: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListPipesResponse {
        let input = ListPipesRequest(
            currentState: currentState, 
            desiredState: desiredState, 
            limit: limit, 
            namePrefix: namePrefix, 
            nextToken: nextToken, 
            sourcePrefix: sourcePrefix, 
            targetPrefix: targetPrefix
        )
        return try await self.listPipes(input, logger: logger)
    }

    /// Displays the tags associated with a pipe.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceResponse {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Displays the tags associated with a pipe.
    ///
    /// Parameters:
    ///   - resourceArn: The ARN of the pipe for which you want to view tags.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceResponse {
        let input = ListTagsForResourceRequest(
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Start an existing pipe.
    @Sendable
    @inlinable
    public func startPipe(_ input: StartPipeRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> StartPipeResponse {
        try await self.client.execute(
            operation: "StartPipe", 
            path: "/v1/pipes/{Name}/start", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Start an existing pipe.
    ///
    /// Parameters:
    ///   - name: The name of the pipe.
    ///   - logger: Logger use during operation
    @inlinable
    public func startPipe(
        name: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> StartPipeResponse {
        let input = StartPipeRequest(
            name: name
        )
        return try await self.startPipe(input, logger: logger)
    }

    /// Stop an existing pipe.
    @Sendable
    @inlinable
    public func stopPipe(_ input: StopPipeRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> StopPipeResponse {
        try await self.client.execute(
            operation: "StopPipe", 
            path: "/v1/pipes/{Name}/stop", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Stop an existing pipe.
    ///
    /// Parameters:
    ///   - name: The name of the pipe.
    ///   - logger: Logger use during operation
    @inlinable
    public func stopPipe(
        name: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> StopPipeResponse {
        let input = StopPipeRequest(
            name: name
        )
        return try await self.stopPipe(input, logger: logger)
    }

    /// Assigns one or more tags (key-value pairs) to the specified pipe. Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values. Tags don't have any semantic meaning to Amazon Web Services and are interpreted strictly as strings of characters. You can use the TagResource action with a pipe that already has tags. If you specify a new tag key, this tag is appended to the list of tags associated with the pipe. If you specify a tag key that is already associated with the pipe, the new tag value that you specify replaces the previous value for that tag. You can associate as many as 50 tags with a pipe.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> TagResourceResponse {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Assigns one or more tags (key-value pairs) to the specified pipe. Tags can help you organize and categorize your resources. You can also use them to scope user permissions by granting a user permission to access or change only resources with certain tag values. Tags don't have any semantic meaning to Amazon Web Services and are interpreted strictly as strings of characters. You can use the TagResource action with a pipe that already has tags. If you specify a new tag key, this tag is appended to the list of tags associated with the pipe. If you specify a tag key that is already associated with the pipe, the new tag value that you specify replaces the previous value for that tag. You can associate as many as 50 tags with a pipe.
    ///
    /// Parameters:
    ///   - resourceArn: The ARN of the pipe.
    ///   - tags: The list of key-value pairs associated with the pipe.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        tags: [String: String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> TagResourceResponse {
        let input = TagResourceRequest(
            resourceArn: resourceArn, 
            tags: tags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Removes one or more tags from the specified pipes.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UntagResourceResponse {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/tags/{resourceArn}", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Removes one or more tags from the specified pipes.
    ///
    /// Parameters:
    ///   - resourceArn: The ARN of the pipe.
    ///   - tagKeys: The list of tag keys to remove from the pipe.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        tagKeys: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UntagResourceResponse {
        let input = UntagResourceRequest(
            resourceArn: resourceArn, 
            tagKeys: tagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }

    /// Update an existing pipe. When you call UpdatePipe, EventBridge only the updates fields you have specified in the request; the rest remain unchanged. The exception to this is if you modify any Amazon Web Services-service specific fields in the SourceParameters, EnrichmentParameters, or TargetParameters objects. For example, DynamoDBStreamParameters or EventBridgeEventBusParameters. EventBridge updates the fields in these objects atomically as one and overrides existing values. This is by design, and means that if you don't specify an optional field in one of these Parameters objects, EventBridge sets that field to its system-default value during the update. For more information about pipes, see  Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    @Sendable
    @inlinable
    public func updatePipe(_ input: UpdatePipeRequest, logger: Logger = AWSClient.loggingDisabled) async throws -> UpdatePipeResponse {
        try await self.client.execute(
            operation: "UpdatePipe", 
            path: "/v1/pipes/{Name}", 
            httpMethod: .PUT, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Update an existing pipe. When you call UpdatePipe, EventBridge only the updates fields you have specified in the request; the rest remain unchanged. The exception to this is if you modify any Amazon Web Services-service specific fields in the SourceParameters, EnrichmentParameters, or TargetParameters objects. For example, DynamoDBStreamParameters or EventBridgeEventBusParameters. EventBridge updates the fields in these objects atomically as one and overrides existing values. This is by design, and means that if you don't specify an optional field in one of these Parameters objects, EventBridge sets that field to its system-default value during the update. For more information about pipes, see  Amazon EventBridge Pipes in the Amazon EventBridge User Guide.
    ///
    /// Parameters:
    ///   - description: A description of the pipe.
    ///   - desiredState: The state the pipe should be in.
    ///   - enrichment: The ARN of the enrichment resource.
    ///   - enrichmentParameters: The parameters required to set up enrichment on your pipe.
    ///   - kmsKeyIdentifier: The identifier of the KMS customer managed key for EventBridge to use, if you choose to use a customer managed key to encrypt pipe data. The identifier can be the key  Amazon Resource Name (ARN), KeyId, key alias, or key alias ARN. To update a pipe that is using the default Amazon Web Services owned key to use a customer managed key instead, or update a pipe that is using a customer managed key to use a different customer managed key, specify a customer managed key identifier. To update a pipe that is using a customer managed key to use the default Amazon Web Services owned key, specify an empty string. For more information, see Managing keys in the Key Management Service Developer Guide.
    ///   - logConfiguration: The logging configuration settings for the pipe.
    ///   - name: The name of the pipe.
    ///   - roleArn: The ARN of the role that allows the pipe to send data to the target.
    ///   - sourceParameters: The parameters required to set up a source for your pipe.
    ///   - target: The ARN of the target resource.
    ///   - targetParameters: The parameters required to set up a target for your pipe. For more information about pipe target parameters, including how to use dynamic path parameters, see Target parameters in the Amazon EventBridge User Guide.
    ///   - logger: Logger use during operation
    @inlinable
    public func updatePipe(
        description: String? = nil,
        desiredState: RequestedPipeState? = nil,
        enrichment: String? = nil,
        enrichmentParameters: PipeEnrichmentParameters? = nil,
        kmsKeyIdentifier: String? = nil,
        logConfiguration: PipeLogConfigurationParameters? = nil,
        name: String,
        roleArn: String,
        sourceParameters: UpdatePipeSourceParameters? = nil,
        target: String? = nil,
        targetParameters: PipeTargetParameters? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UpdatePipeResponse {
        let input = UpdatePipeRequest(
            description: description, 
            desiredState: desiredState, 
            enrichment: enrichment, 
            enrichmentParameters: enrichmentParameters, 
            kmsKeyIdentifier: kmsKeyIdentifier, 
            logConfiguration: logConfiguration, 
            name: name, 
            roleArn: roleArn, 
            sourceParameters: sourceParameters, 
            target: target, 
            targetParameters: targetParameters
        )
        return try await self.updatePipe(input, logger: logger)
    }
}

extension Pipes {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: Pipes, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension Pipes {
    /// Return PaginatorSequence for operation ``listPipes(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listPipesPaginator(
        _ input: ListPipesRequest,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListPipesRequest, ListPipesResponse> {
        return .init(
            input: input,
            command: self.listPipes,
            inputKey: \ListPipesRequest.nextToken,
            outputKey: \ListPipesResponse.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listPipes(_:logger:)``.
    ///
    /// - Parameters:
    ///   - currentState: The state the pipe is in.
    ///   - desiredState: The state the pipe should be in.
    ///   - limit: The maximum number of pipes to include in the response.
    ///   - namePrefix: A value that will return a subset of the pipes associated with this account. For example, "NamePrefix": "ABC" will return all endpoints with "ABC" in the name.
    ///   - sourcePrefix: The prefix matching the pipe source.
    ///   - targetPrefix: The prefix matching the pipe target.
    ///   - logger: Logger used for logging
    @inlinable
    public func listPipesPaginator(
        currentState: PipeState? = nil,
        desiredState: RequestedPipeState? = nil,
        limit: Int? = nil,
        namePrefix: String? = nil,
        sourcePrefix: String? = nil,
        targetPrefix: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListPipesRequest, ListPipesResponse> {
        let input = ListPipesRequest(
            currentState: currentState, 
            desiredState: desiredState, 
            limit: limit, 
            namePrefix: namePrefix, 
            sourcePrefix: sourcePrefix, 
            targetPrefix: targetPrefix
        )
        return self.listPipesPaginator(input, logger: logger)
    }
}

extension Pipes.ListPipesRequest: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> Pipes.ListPipesRequest {
        return .init(
            currentState: self.currentState,
            desiredState: self.desiredState,
            limit: self.limit,
            namePrefix: self.namePrefix,
            nextToken: token,
            sourcePrefix: self.sourcePrefix,
            targetPrefix: self.targetPrefix
        )
    }
}
